local bolinggan = fk.CreateSkill {
  name = "bolinggan",
}

Fk:loadTranslationTable{
  ["bolinggan"] = "灵感",
  [":bolinggan"] = "你使用一张牌时，若此牌名是你本轮第一次使用，你摸一张牌。",

  ["$bolinggan1"] = "俯仰各有志，得酒诗自成。",
  ["$bolinggan2"] = "今朝有酒今朝醉，明日愁来明日愁。",
}

bolinggan:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(bolinggan.name) and
      data.extra_data and data.extra_data.bolinggan
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, bolinggan.name)
  end,

  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(bolinggan.name, true) and
      not table.contains(player:getTableMark(bolinggan.name .. "_round"), data.card.trueName)
  end,
  on_refresh = function (self, event, target, player, data)
    -- 使用带_round后缀的标记名，确保每轮重置
    player.room:addTableMark(player, bolinggan.name .. "_round", data.card.trueName)
    data.extra_data = data.extra_data or {}
    data.extra_data.bolinggan = true
  end,
})

-- 回合结束时清除本轮标记
bolinggan:addEffect(fk.TurnEnd, {
  on_refresh = function(self, event, target, player, data)
    player.room:removeTableMark(player, bolinggan.name .. "_round")
  end,
})

bolinggan:addLoseEffect(function (self, player, is_death)
  player.room:setPlayerMark(player, bolinggan.name, 0)
end)

return bolinggan
